package controller;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.entity.Dish;
import service.Impl.DishServiceImpl;
import util.ResultUtil;

import java.io.IOException;
import java.util.List;

@WebServlet("/admin/dish/list")
public class DishByListIdController extends HttpServlet {
    //根据菜品分类id查询菜品

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int categoryId=Integer.parseInt(req.getParameter("categoryId"));
        DishServiceImpl ds=new DishServiceImpl();
        List<Dish> dishList=ds.getCateDishes(categoryId);
        String json= ResultUtil.getJSON(dishList);
        resp.getWriter().println(json);

    }
}
